package com.asia5b.a5mall.middleware.model.goods

import com.asia5b.a5mall.middleware.model.base.BaseModel
import com.asia5b.a5mall.middleware.utils.WTimeUtils
import com.google.gson.annotations.SerializedName
import java.io.Serializable

/**
 * Created by zhangyuncai on 2019/12/21.
 * @Note   商品评论ViewModel
 */
class Goods2CommenModel : BaseModel() {

    /**用户姓名*/
    @SerializedName(value = "userName", alternate = ["member_name"])
    var userName = ""

    /**用户头像*/
    @SerializedName(value = "userFace", alternate = ["member_face"])
    var userFace = ""

    /**评论时间*/
    val create_time = 0L
    var commentTime = ""
        get() {
            return WTimeUtils.format("${create_time * 1000}", WTimeUtils.text_yyyy_MM_dd_HH_mm_ss)
        }

    /**购买时间*/
    var buyTime = ""
        get() {
            return commentTime
        }

    /**图片集合*/
    var images = arrayListOf<String>()
        get() {
            if (field.isNullOrEmpty()) {
                return arrayListOf<String>()
            }
            return field
        }

    /**评分*/
    var rating = 0.0f
        get() {
            if (grade == "good") {
                return 5.0f
            } else if (grade == "neutral") {
                return 3.0f
            } else if (grade == "bad") {
                return 1.0f
            }
            return 3.0f
        }
    var grade = ""
    var gradeInt = 0
        get() {
            if (grade == "good") {
                return 3
            } else if (grade == "neutral") {
                return 2
            } else if (grade == "bad") {
                return 1
            }
            return 3
        }

    /**评论详细*/
    var content = ""
    val reply: ReplyModel? = null

    /**店家回复*/
    var replyString = ""
        get() {
            return reply?.content ?: ""
        }


}

class ReplyModel : BaseModel() {
    var content = ""
}


/*
{
"comment_id": 425,
"goods_id": 8211,
"sku_id": 24095,
"member_id": 138,
"seller_id": 64,
"member_name": "sasa",
"member_face": null,
"goods_name": "木柄硅胶平底锅漏铲煎铲",
"content": "此商品默认好评",
"create_time": 1575388802,
"have_image": 0,
"status": 1,
"grade": "good",
"order_sn": "20191203000010",
"reply_status": 0,
"audit_status": "PASS_AUDIT",
"comments_type": "INITIAL",
"parent_id": 0,
"images": null,
"replyString": null,
"additional_comment": null,
"goods_images": {
    "img_id": 19011,
    "goods_id": 8211,
    "thumbnail": "http:\/\/47.88.173.86:82\/testShopImg\/AE7B9E897062423B980DDEAE2238E349_300x300.jpeg",
    "small": "http:\/\/47.88.173.86:82\/testShopImg\/AE7B9E897062423B980DDEAE2238E349_400x400.jpeg",
    "big": "http:\/\/47.88.173.86:82\/testShopImg\/AE7B9E897062423B980DDEAE2238E349_800x800.jpeg",
    "original": "http:\/\/47.88.173.86:82\/testShopImg\/AE7B9E897062423B980DDEAE2238E349.jpeg",
    "tiny": null,
    "isdefault": 1,
    "sort": 0
},
"member_shop_score": null
},
 */

/*
"reply": {
"reply_id": 26,
"comment_id": 901,
"content": "多谢大家的支持",
"create_time": 1594372903,
"role": "SELLER",
"path": null,
"reply_type": "INITIAL"
},
 */
